package com.ziyunying.weather.di

import android.content.Context
import com.ziyunying.weather.api.AMapLocationApi
import com.ziyunying.weather.repository.LocationRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object LocationModule {

    @Provides
    @Singleton
    fun provideAMapLocationApi(@ApplicationContext context: Context): AMapLocationApi {
        return AMapLocationApi(context)
    }

    @Provides
    @Singleton
    fun provideLocationRepository(
        @ApplicationContext context: Context,
        locationApi: AMapLocationApi
    ): LocationRepository {
        return LocationRepository(context, locationApi)
    }
}